package com.xm.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xm.mapper.UserDataMapper;
import com.xm.pojo.PageVo;
import com.xm.pojo.UserData;
import com.xm.service.UserDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class UserDataServiceImpl implements UserDataService {

    @Autowired
    UserDataMapper mapper;

    public int insertUserDataService(UserData userData) {
        return mapper.insertUserData(userData);
    }

    public int deleteUserDataService(String realname) {
        return mapper.deleteUserData(realname);
    }

    public int updateUserDataService(UserData userData) {
        return mapper.updateUserData(userData);
    }

    public UserData queryByRealnameService(String realname) {
        return mapper.queryByRealname(realname);
    }

    public PageInfo<UserData> queryListService(PageVo<String> pageVo) {
        PageHelper.startPage(pageVo.getCurrentPage(),pageVo.getPageSize());
        List<UserData> UserDataList = mapper.queryList(pageVo.getEntity());
        PageInfo<UserData> UserDataPageInfo = new PageInfo<UserData>(UserDataList);
        return UserDataPageInfo;
    }

    public List<UserData> queryAllService() {
        return mapper.queryAll();
    }
}
